<?php
function getnav($n){
	foreach($n->attributes() as $a => $b){
		$attr[$a]=$b;
	}
	if($n->getname()=="link"){
		echo "<li><a href='index.php?page=",$attr["href"],"'>",ucfirst($attr["href"]),"</a></li>";
		}
	else{
		echo "<li><a href='index.php?page=",$attr["href"],"'>",ucfirst($attr["href"]),"</a><ul>";
		loop($n);
		echo "</ul></li>";
	}
}
function loop($n){
	foreach( $n->children() AS $child ){
	getnav($child);
	}
	}
if (file_exists('modules/nav/nav.xml')) {
    $nav = simplexml_load_file('modules/nav/nav.xml');
    echo "<ul>";
	loop($nav);
	echo "</ul>";

} else {
    exit('The theme doesnt exist or corrupt');
}
?>
